from google.appengine.ext import db

class Company(db.Model):
	name        = db.StringProperty()
	slug        = db.StringProperty()
	email       = db.StringProperty()
	phone       = db.StringProperty()
	address     = db.StringProperty()
	website     = db.StringProperty()
	description = db.TextProperty()

	@classmethod
	def create_slug(cls, value):
		value = value.replace('-', '').replace(' ', '-')
		valid_chars = '-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
		return ''.join(c for c in value if c in valid_chars)
	
	@classmethod
	def get_by_name(cls, name):
		return cls.all().filter('name =', name).get()	
	
	@classmethod
	def get_by_slug(cls, slug):
		return cls.all().filter('slug =', slug).get()
	
	
	